<?php
/**
 * @var $data Training
 */
$thumb = '';
if($data->image_id){
	$thumb = '/upload/images/thumb/product150/'.substr_replace($data->image->path,'',0,14);
	if(!is_file(Yii::getPathOfAlias('webroot').$thumb)){
		Yii::import('application.extensions.image.Image');
		$image = new Image(Yii::getPathOfAlias('webroot').'/'.$data->image->path);
		$image->resize(150, 100);
		if(!is_dir(Yii::getPathOfAlias('webroot').'/upload/images/thumb/product150/')){
			mkdir(Yii::getPathOfAlias('webroot').'/upload/images/thumb/product150/');
			chmod(Yii::getPathOfAlias('webroot').'/upload/images/thumb/product150/',0777);
		}
		$image->save(Yii::getPathOfAlias('webroot').$thumb);
	}
}
?>
<div class="item">
    <?php if($data->image_id): ?><div class="img"><a href="<?php echo $this->createUrl('view', array('id' => $data->id, 'title' => Yii::app()->func->safeTitle($data->name))); ?>"><img src="<?php echo Yii::app()->baseUrl.$thumb; ?>"></a></div><?php endif?>
    <div class="title">
        <?php echo $data->name; ?>
    </div>
    
    <div class="price"><span style="color:#6C6C6C;font-size:11px;">Giá:</span> <span style="color:#970D00;font-size;12px;font-weight: bold;"><?php echo number_format($data->price,0,',','.') ; ?><span style="font-size:10px;padding:0px 0px 5px 2px;text-decoration: underline;">đ</span></span> </div>
    
</div>